#include "KevinToolBoxDlg.h"
#include "./ui_KevinToolBoxDlg.h"

#include <QDebug>
#include <QStatusBar>

KevinToolBoxDlg::KevinToolBoxDlg(QWidget* parent)
    : QMainWindow(parent)
    , ui(new Ui::KevinToolBoxDlg)
    , widget1(nullptr)
    , widget2(nullptr) {
    ui->setupUi(this);
    widget1 = new KevinToolBoxWdt(ui->frameRight);
    widget2 = new KevinLayoutWdt(ui->frameRight);

    ui->verticalLayoutFrameRight->addWidget(widget1);
    ui->verticalLayoutFrameRight->addWidget(widget2);

    connect(ui->pushButtonWidget1, SIGNAL(clicked()), this, SLOT(showWidget1()));
    connect(ui->pushButtonWidget2, SIGNAL(clicked()), this, SLOT(showWidget2()));
    connect(ui->pushButtonStudySlot, SIGNAL(clicked()), this, SLOT(studySlot()));
}
KevinToolBoxDlg::~KevinToolBoxDlg() {
    widget1 = nullptr;
    widget2 = nullptr;
    delete ui;
}
int KevinToolBoxDlg::build() {
    this->setStyleSheet(styleSheet);
    widget2->setStyleSheet(styleSheet);
    showWidget1();

    return 0;
}

int KevinToolBoxDlg::showWidget1() {
    qDebug() << "  KevinToolBoxDlg::showWidget1()";
    widget1->show();
    widget2->hide();
    ui->statusbar->showMessage("QToolBox 方式");
    return 0;
}

int KevinToolBoxDlg::showWidget2() {
    qDebug() << "  KevinToolBoxDlg::showWidget2()";
    widget1->hide();
    widget2->show();
    this->statusBar()->showMessage("按钮方式");
    return 0;
}
int KevinToolBoxDlg::studySlot() {
    qDebug() << "  KevinToolBoxDlg::studySlot()";
    widget1->study();
    widget2->study();
    return 0;
}
